<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ZDH 血源分析明细</title>
    <meta name="keywords" content="ZDH 血源分析明细">
    <meta name="description" content="ZDH 血源分析明细">

    <link rel="shortcut icon" href="img/favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="css/plugins/chosen/chosen.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/datetimepicker/datetimepicker.css" rel="stylesheet">
    <link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="css/jsmind/jsmind.css">
</head>

<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
    <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>血缘关系图</h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                    <a class="dropdown-toggle" data-toggle="dropdown" href="buttons.html#">
                        <i class="fa fa-eye"></i>
                    </a>
                    <ul class="dropdown-menu dropdown-user">
                        <li><a href="javascript:void(0);" onclick="getResourceDesc()">功能说明</a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="ibox-content col-sm-12" style="height: 98%">
                <div class="form-group">
                    <div class="text-center">
                        <button  class="btn btn-primary btn-sm" οnsubmit='return false'
                                type="button" style="background-color: #00bb00">上游
                        </button>
                        <button  class="btn btn-primary btn-sm" οnsubmit='return false'
                                 type="button" style="background-color: #FF9900">下游
                        </button>
                        <button  class="btn btn-primary btn-sm" οnsubmit='return false'
                                 type="button" style="background-color: #C2DFFF">当前节点
                        </button>
                    </div>
                </div>
                <div class="form-group">
                    <div  class="col-sm-12">
                        <div class="container device col-sm-12">
                            <div class="deviceLeft">
<!--                                <div class="deviceLeft_box">-->
<!--                                    <div class="node node1css" data-type="tasks">ETL任务</div>-->
<!--                                    <div class="node node1css" data-type="shell">SHELL</div>-->
<!--                                </div>-->
                                <input id="refash" οnsubmit='return false' type="button" class="btn btn-primary form-control"
                                       style="margin-bottom:0px" value="分析血源"/>
                            </div>
                            <div id="deviceRight">
                                <div id="m1" style="width: 80%;float:left;"></div>
                                <div id="m2" style="width: 20%;float:right;">
                                    <div class="form-group">
                                        <label class="control-label">数据源说明</label>
                                        <div>
                                            <input id="data_source_context" name="data_source_context" type="text"
                                                   placeholder="数据源说明" class="form-control" aria-required="true" readonly > </span>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label">数据源类型</label>
                                        <div>
                                            <input id="data_source_type" name="data_source_type" type="text"
                                                   placeholder="数据源类型" class="form-control" aria-required="true" readonly > </span>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label">节点</label>
                                        <div>
                                            <input id="topic" name="topic" type="text"
                                                   placeholder="节点" class="form-control" aria-required="true" readonly > </span>
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
</div>
<script src="js/zdh_common.js"></script>
<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/jquery-ui.custom.min.js?v=2.1.4"></script>
<script src="js/jquery-ui-1.10.4.min.js"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<!-- Chosen -->
<script src="js/plugins/chosen/chosen.jquery.js"></script>


<script src="js/plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>

<script src="js/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>

<!-- Bootstrap table -->
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="js/plugins/layer/laydate/laydate.js"></script>
<!-- layer javascript -->
<script src="js/plugins/layer/layer.min.js"></script>

<script type="text/javascript" src="js/jsmind/jsmind.js"></script>
<script type="text/javascript" src="js/jsmind/jsmind.draggable.js"></script>
<script type="text/javascript" src="js/jsmind/jsmind.screenshot.js"></script>

<!--<script type="text/javascript" src="js/jsplumb/blood_source_index.js"></script>-->
<script type="text/javascript">


    function get_color_by_status(stream_type){
        //上游
        if(stream_type == "upstream")
            return "#00bb00";
        //下游
        if(stream_type == "downstream")
            return "#00FFFF";

        return "#C2DFFF";
    }

    var _jm = null;
    function open_empty(){
        var options = {
            container:'m1',
            theme:'greensea',
            editable:false,//是否可编辑
        };
        _jm = jsMind.show(options);
        _jm.end_edit();
        // _jm = jsMind.show(options,mind);
    }
    open_empty();
    function open_jsmind(data){
        var mind = {
            "meta":{
                "name":"jsMind remote",
                "author":"hizzgdev@163.com",
                "version":"0.2"
            },
            //"format":"node_tree",
            "format": "node_array",
            "data": data
        };
        _jm.show(mind);
        _jm.end_edit();
    }

</script>
<script>
    var tmp_source_json = {};
    $(document).ready(function () {

        window.document.addEventListener('dblclick',function(){
            var selected_node = _jm.get_selected_node();
            $('#data_source_context').val(tmp_source_json[selected_node.id].data_source_context);
            $('#data_source_type').val(tmp_source_json[selected_node.id].data_source_type);
            $('#topic').val(selected_node.topic);
        });

        var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
        var params = url.substr(1);//去掉问号
        var pa = params.split("&");
        var s = new Object();//定义一个全局变量-存储任务ID
        for (var i = 0; i < pa.length; i++) {
            s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
        }

        function refash_graph(){
            $.ajax({
                url : server_context+"/blood_source_detail",
                data : {"input":s.input, "input_md5":s.input_md5},
                type : "post",
                dataType : "json",
                success : function(data) {
                    if(data.code != "200"){
                        layer.msg(data.msg);
                        return ;
                    }
                    console.info("success");
                    if(data.result.length>0){
                        for(var i=0;i<data.result.length;i++){
                            tmp_source_json[data.result[i].id]=data.result[i].source_json;
                        }
                    }
                    open_jsmind(data.result);
                    layer.msg("分析完成");
                },
                error: function (data) {
                    console.info("error: " + data.responseText);
                }

            });
        }
        $('#refash').click(function () {
            refash_graph();
        });

        $('#refash').click();
    });
</script>
</body>

</html>